<template>
	<view class="all">
		<view class="content">
			<image style="width: 100%;" src="/static/040f77e46cbb6ba3ef53ecdc9e0d2a5.png"></image>
			<view class="flex_content">
				<view class="item">
					<view class="">
						<image src="/static/55dbdc24d4b880b7f444a21c94686b0.png"></image>
					</view>
					<p class="">
						点餐
					</p>
				</view>
				<view class="item" style="width: 0%;
					height: 300rpx;border: 1px solid #ccc;margin: 25rpx 0;">
					<p></p>
				</view>
				<view class="item">
					<image src="/static/3c1057233edfdd099112a8b6a8cdd33.png"></image>
					<p class="">
						会员中心
					</p>
				</view>
			</view>
			<!-- <van-button>vant 按钮</van-button> -->

			<!-- <image src="/static/040f77e46cbb6ba3ef53ecdc9e0d2a5.png"></image> -->
			<!-- 	<image class="logo" src="/static/logo.png"></image>
			<view class="text-area">
				<text class="title">{{title}}</text>
			</view> -->
		</view>
		<gift></gift>
		<NearbyStore />
		
		<uni-section type="line" padding>
			<!-- 因为swiper特性的关系，请指定swiper的高度 ，swiper的高度并不会被内容撑开-->
			<swiper class="swiper" :indicator-dots="true">
				<swiper-item>
					<uni-grid :column="3" @change="change" :showBorder="false" :square="false">
						<uni-grid-item v-for="(item, index) in list" :index="index" :key="index">
							<view class="grid-item-box">
								<image :src="item.url" class="image" mode="aspectFill" style="width: 100px;height: 100px;"/>
								<p class="text text1">{{ item.text }}</p>
								<p class="text text2">￥{{ item.price }} <i>份</i> </p>
							</view>
<!-- 							<uni-card class="grid-item-box">
								<image :src="item.url" class="image" mode="aspectFill"
									style="width: 100px;height: 100px;" />
								<view class="text1">{{ item.text }}</view>
								<view class="text2">￥{{ item.price }} <i>份</i> </view>
							</uni-card> -->
						</uni-grid-item>
					</uni-grid>
				</swiper-item>
				<!-- 	<swiper-item>
					<uni-grid :column="3" :highlight="true" @change="change">
						<uni-grid-item v-for="(item, index) in list" :index="index" :key="index">
							<view class="grid-item-box">
								<image :src="item.url" class="image" mode="aspectFill"  style="width: 50px;height: 50px;"/>
								<text class="text">{{ item.text }}</text>
							</view>
						</uni-grid-item>
					</uni-grid>
				</swiper-item> -->
				<!-- 	<swiper-item>
					<uni-grid :column="3" :highlight="true" @change="change">
						<uni-grid-item v-for="(item, index) in list" :index="index" :key="index">
							<view class="grid-item-box">
								<image :src="item.url" class="image" mode="aspectFill"  style="width: 50px;height: 50px;"/>
								<text class="text">{{ item.text }}</text>
							</view>
						</uni-grid-item>
					</uni-grid>
				</swiper-item> -->
			</swiper>
		</uni-section>
		<!-- 		<uni-section title="动态加载" type="line" padding>
					<view class="grid-dynamic-box">
						<uni-grid :column="3" :highlight="true" @change="change">
							<uni-grid-item v-for="(item, index) in dynamicList" :index="index" :key="index">
								<view class="grid-item-box" :style="{'backgroundColor':item.color}">
									<image :src="item.url" class="image" mode="aspectFill" />
									<text class="text">{{ item.text }}</text>
								</view>
							</uni-grid-item>
						</uni-grid>
					</view>
					<button type="primary" @click="add">点击添加一个宫格</button>
					<button v-if="dynamicList.length !== 0" type="primary" style="margin-top: 15px;"
						@click="del">点击删除一个宫格</button>
				</uni-section> -->
	</view>
</template>

<script>
	import gift from "./components/gift/gift.vue"
	import NearbyStore from "./components/NearbyStore/index.vue"
	// import {button} from 'vant'

	export default {
		data() {
			return {
				title: 'Hello',
				dynamicList: [],
				list: [{
						url: '/static/shop/d325cca31cf16e99d67f6f6bef39db9.jpg',
						text: '岐山哨子面',
						badge: '0',
						type: "primary",
						price: '18',
					},
					{
						url: '/static/8eb74d2b52ebbb13eb5791b27283145.png',
						text: '羊肉泡馍',
						badge: '1',
						type: "success",
						price: '35',
					},
					{
						url: '/static/55dbdc24d4b880b7f444a21c94686b0.png',
						text: '油泼臊子面',
						badge: '99',
						type: "warning",
						price: '22',
					},
				]
			}
		},
		components: {
			gift,
			NearbyStore
		},
		onLoad() {

		},
		methods: {

			add() {
				if (this.dynamicList.length < 9) {
					this.dynamicList.push({
						url: `/static/c${this.dynamicList.length+1}.png`,
						text: `Grid ${this.dynamicList.length+1}`,
						color: this.dynamicList.length % 2 === 0 ? '#f5f5f5' : "#fff"
					})
				} else {
					uni.showToast({
						title: '最多添加9个',
						icon: 'none'
					});
				}
			},
			del() {
				this.dynamicList.splice(this.dynamicList.length - 1, 1)
			},
			change(e) {
				let {
					index
				} = e.detail
				this.list[index].badge && this.list[index].badge++

				uni.showToast({
					title: `点击第${index+1}个宫格`,
					icon: 'none'
				})
			},

		}
	}
</script>

<style lang="scss">
	.all {
		background-color: #f5f5f5;
	}

	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;

		>image {
			// margin-top: 20px;
		}

		.flex_content {
			width: 95%;
		}
	}

	.flex_content {
		width: 80%;
		margin: auto;
		margin-top: 10px;
		display: flex;
		flex-wrap: nowrap;
		justify-content: space-between;
		background-color: #fff;
		border-radius: 4%;

		.item {
			width: 40%;
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;
			align-items: center;

			:nth-child(1),
			:nth-child(3) {
				margin-top: 20rpx;
				padding: 0 10px;
			}

			image {
				align-items: center;
			}

			p {
				width: 80%;
				margin: auto;
				text-align: center;
				font-size: 48rpx;
			}
		}

		image {
			width: 200rpx;
			height: 200rpx;
		}

	}

	.swiper {
		height: 200px;
		margin: 0;
		.grid-item-box {
			background-color: #fff;
			display: flex;
			// height: 200px;
			margin: 10px auto;
			margin: 0;
			width: 100%;
			flex-wrap: wrap;
			justify-content: space-around;
			.text1 {
				width: 100%;
				text-align: center;
			}
			.text2 {
				text-align: left;
				font-weight: 900;
				i {
					font-weight: 400;
				}
			}
		}
	}
</style>
